package com.second.oa.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.second.oa.dao.PowerDao;
import com.second.oa.domain.Power;

public class PowerDaoImpl extends BaseDaoImpl<Power> implements PowerDao {

	public void add(Power t) throws SQLException {
	}

	public void update(Power t) throws SQLException {
	}

	public void delete(String id) throws SQLException {
		
	}

	/**
	 * 设置分页方法为不分页
	 */
	@Override
	public List<Power> list(String sql, int pn, int pr, Object... params)
			throws SQLException {
		return super.list(sql, params);
	}
	
	/*
	 * 
	 * select * from t_power
	 * */
	@Override
	protected Power transform(ResultSet res) throws SQLException {
		
		Power p = new Power();
		p.setId(res.getString("id"));
		p.setName(res.getString("name"));
		p.setPowerValue(res.getString("power_value"));
		p.setPowerLevel(res.getInt("power_level"));
	    p.setOrderValue(res.getInt("order_value"));
		p.setIsMenu(res.getInt("is_menu"));
	    
		Power parent = null;
		if(res.getString("parent") != null) {
			parent = new Power();
			parent.setId(res.getString("parent"));
			p.setParent(parent);
		}
		
		return p;
	}

}
